package com.tanhua.dubbo.api;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tanhua.dubbo.mapper.BlackListMapper;
import com.tanhua.dubbo.mapper.UserInfoMapper;
import com.tanhua.model.domain.BlackList;
import com.tanhua.model.domain.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author lifeihu
 * @date 2021/12/25
 * @TIME:19:46
 */
public class BlackListApiImpl implements BlackListApi {
    @Autowired
    private UserInfoMapper userInfoMapper;
    @Autowired
    private BlackListMapper blackListMapper;
    @Override
    public IPage<UserInfo> findByUserId(Long userId, int page, int size) {
        Page<UserInfo> userInfoPage = new Page<>(page,size);
//        IPage<UserInfo> userInfoIPage = userInfoMapper.findByPage(userInfoPage, userId);
        IPage<UserInfo> iPage = userInfoMapper.findByPage(userInfoPage, userId);
        return iPage;
    }

    @Override
    public void removeById(Long userId,Long blackUserId) {
        LambdaUpdateWrapper<BlackList> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(BlackList::getUserId,userId);
        wrapper.eq(BlackList::getBlackUserId,blackUserId);
        blackListMapper.delete(wrapper);
    }
}
